#基础
person_info = {
    "name":"Alex",
    "age":30,
    "country":"USA",
    "language":["English","Spanish"],
    "is_student":False
}
#1
print(person_info['name'])
#2
person_info['age'] = 31
print(person_info['age'])
#3
person_info['height'] = 175
print(person_info)
#4
del person_info["is_student"]
print(person_info)
#5
for e in person_info.items():
    print(e)
#6
if "email" not in person_info:
    person_info['email'] = "alex@exmpale.com"
    print(person_info)
#7
person_info['language'] = ["English"]
print(person_info['language'])
#8
print(len(person_info['language']))
#9
person_info['language'].append('French')
print(person_info['language'])
#10
for i in range(1,4):
    hobby_key = 'hobby{}'.format(i)
    hobby_value = "hobby{}值".format(i)
    person_info[hobby_key] = hobby_value
print(person_info)
#进阶
employees = {
    101: {
        "name": "Alice",
        "age": 30,
        "gender": "Female",
        "position": "Data Scientist",
        "team": "Research",
        "salary_history": [70000, 80000, 90000]
    }
}
#1
employees[102] = {
    "name": "sbs",
    "age": 22,
    "gender": "Male",
    "position": "Data musician",
    "team": "dengta",
    "salary_history": [10000, 20000, 30000]
}
print(employees)
#2
del employees[102]
print(employees)
#3
employees[101]["age"] = 42
print(employees[101]["age"])
#4
employees[101]["salary_history"].append(95000)
#5
salaries = employees[101]["salary_history"]
avg_salary = sum(salaries) / len(salaries)
print(avg_salary)
#6
over_25 = []
for emp_id, emp_info in employees.items():
    if emp_info["age"] > 25:
        over_25.append((emp_id, emp_info["name"]))
print(over_25)
#7
for  emp_info1,emp_info in employees.items():
    latest_salary = emp_info["salary_history"][-1]
    employees[emp_info1]["bonus"] = latest_salary * 0.10
print(employees)
#8
employees[101]["position"] = "Senior Data Scientist"
print(employees[101]["position"])
#9
for emp_info in employees.keys():
    del employees[emp_info]["gender"]
print(employees)
#10
employees1 = {}
for emp_id,emp_info in employees.items():
    employees1 = {emp_id : {"name": emp_info["name"],"position": emp_info["position"]}}
print(employees1)